<?php $__env->startSection('title','积分明细'); ?>

<?php $__env->startSection('css'); ?>
    <link rel="stylesheet" href="<?php echo e(asset('/css/iscroll.css')); ?>">
    <style>
        body{
            background-color: #f0eff6;
        }
        .body{
            font-size: 16px;
        }
        .top{
            background: -webkit-linear-gradient(left top, #dec07a , #d79705); /* Safari 5.1 - 6.0 */
            background: -o-linear-gradient(bottom right, #dec07a, #d79705); /* Opera 11.1 - 12.0 */
            background: -moz-linear-gradient(bottom right, #dec07a, #d79705); /* Firefox 3.6 - 15 */
            background: linear-gradient(to bottom right, #dec07a , #d79705); /* 标准的语法（必须放在最后） */
            text-align: center;
            line-height: 42px;
            padding-top: 30px;
            background-size: 100% 100%;
            margin-top: -58px;
            padding-bottom: 25px;
        }
        .top>p{
            color: #fff;
        }
        .top>p:nth-child(2){
            font-size: 45px;
        }

        /*积分明细列表*/
        .list_content{
            /*margin-bottom: 50px;*/
            height: 300px;
            overflow: scroll;
        }
        .list_body{
            padding: 0 15px;
        }
        .credits_time{
            padding: 0 15px;
            height: 30px;
            background-color: #f0eff6;
            font-size: 14px;
            color: #706969;
            line-height: 30px;
        }
        .credits_list{
            background-color: #fff;
        }
        .credits_item{
            border-bottom: 1px solid #f0eff6;
        }
        .credits_des{
            display: inline-block;
            width: 80%;
            height: 60px;
            -moz-box-sizing: border-box;  /*Firefox3.5+*/
            -webkit-box-sizing: border-box; /*Safari3.2+*/
            -o-box-sizing: border-box; /*Opera9.6*/
            -ms-box-sizing: border-box; /*IE8*/
            box-sizing: border-box;
            line-height: 26px;
            padding-top: 6px;
        }
        .nav_back,.nav_right{
            color: #fff;
            display: inline-block;
        }
        .nav_right{
            float: right;
        }
        .nav_right>a{
            color: #fff;
        }
        .credits_des>p:nth-child(1){
            color: #000;
            font-weight: 500;
        }
        .credits_des>p:nth-child(2){
            color: #706969;
            font-size: 13px;
        }
        .credits_num{
            margin-top: 20px;
            float: right;
        }

        .empty_recored{
            text-align: center;
        }
        .weui-loadmore_line .weui-loadmore__tips{
            background-color: rgba(1,1,1,0);
        }
    </style>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('container'); ?>
    <div class="body">
        <div class="nav_bar">
            <div class="nav_back"></div>
        </div>

        
        <div class="top">
            <p>当前积分</p>
            <p><?php echo e($mycard->remain_credits); ?></p>
        </div>
        

        
        <div class="list_content" id="wrapper">

            <div class="iscorll">
                <div class="content">
                    <?php echo $__env->make('user.list._credits_list', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

                </div>
                <div class="more"><i class="pull_icon"></i><span>上拉加载...</span></div>
            </div>

        </div>

    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('js'); ?>
    <script src="<?php echo e(asset('/js/iscroll.js')); ?>" type="text/javascript"></script>
    <script>
        //计算waper高度
        var sum_height = $(window).height();
        var op_height = $('.top').outerHeight(true);

        $('.list_content').height(sum_height-op_height);

        if($('.list_body').length*1<10){
            if($('.empty').length<=0){
                $('.content').append('<div class="weui-loadmore weui-loadmore_line empty" style="display: none">\n' +
                    '                        <span class="weui-loadmore__tips" >到底了:(</span>\n' +
                    '                    </div>');
            }

            $('.more').remove();
            $('.weui-loadmore').css('display','block');
        }

        if($('.empty').length>0){
            $('.more').remove();
        }

        var page=1;
        var myscroll = new iScroll("wrapper",{
            onScrollMove:function(){
                if($('.empty').length>0){
                    $('.more').remove();
                    return ;
                }
                if (this.y<(this.maxScrollY)) {
                    $('.pull_icon').addClass('flip');
                    $('.pull_icon').removeClass('loading');
                    $('.more span').text('释放加载...');
                }else{
                    $('.pull_icon').removeClass('flip loading');
                    $('.more span').text('上拉加载...')
                }
            },
            onScrollEnd:function(){
                if($('.empty').length>0){
                    $('.more').remove();
                    return ;
                }

                if ($('.pull_icon').hasClass('flip')) {
                    $('.pull_icon').addClass('loading');
                    $('.more span').text('加载中...');
                    //pullUpAction();
                    $.ajax({
                        url:'/ajax/getCreditsRecords',
                        type:'post',
                        data:{'_token':window.laravel_csrf_token,'page':++page},
                        success:function(res){
                            $('.content').append(res);
                            dealRepeat();
                            myscroll.refresh();

                            if($('.empty').length>0)
                                $('.more').remove();

                        },
                        error:function(err){
                            myscroll.refresh();
                            console.log(err);
                        }
                    });

                }

            },
            onRefresh:function(){
                $('.pull_icon').removeClass('flip loading');
                $('.more span').text('上拉加载...');
            }

        });


        //处理重复
        function dealRepeat() {

            $('.credits_time').each(function(key,item){
                var lkey = $(item).text();
                if($('.date_'+lkey).length>1){
                    $('.date_'+lkey).each(function(k,v){
                        if(k>0){
                            $(v).remove();
                        }
                    });
                }
            });
        }


    </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts._main', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>